home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / DefaultLevelConfig.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  1.6 KB  |  62 lines

  1.  
  2. -- Start at low music:
  3. CurMusicLevel = 0
  4.  
  5. ---------------------------------------------------------------------------
  6. -- Generic Level Exit function
  7. ---------------------------------------------------------------------------
  8.  
  9. function LevelExitDesc()
  10.     if ( GameState == QuitLevel )then
  11.         G.ActiveBackGround( 2 );
  12.         
  13.         TraitorTalk( "Hey where are you going!?!" )
  14.         
  15.         return "YOU QUIT!";
  16.     elseif(  GameState == Victory )then
  17.         G.ActiveBackGround( 1 );
  18.         return "YOU WON!";
  19.     elseif( GameState == Defeat )then
  20.         G.ActiveBackGround( 2 );
  21.         
  22.         TraitorTalk( "Oh no! The base, it's been invaded!" )    
  23.         
  24.         return "YOU LOST!";
  25.     end
  26. end
  27.  
  28. ---------------------------------------------------------------------------
  29. -- Generic Level Update function
  30. ---------------------------------------------------------------------------
  31.  
  32. -- Not really a victory check, this checks for defeat!
  33. function CheckLevelCompletion()
  34.     local tower = G.GetCogName("Tower");
  35.     
  36.     if( not tower.IsValid() ) then
  37.         G.SetGameState( Defeat );    
  38.     end
  39.     
  40.     if( not( GameState == InLevel ) ) then
  41.         dofile( "Scripts/GameOver.lua" );        -- The gameover script should do all exit functionality:
  42.         GMain["LevelUpdate"] = nil;
  43.     end        
  44. end
  45.     
  46. function LevelUpdate()
  47.     
  48.     -- Make sure the player isn't trying to exit the level
  49.     CheckLevelCompletion()
  50.     UpdateGameMusic()
  51.     -- This is the intro, where you check for level 
  52.     if( levelRoutine ) then    
  53.         local con, error = coroutine.resume( levelRoutine )
  54.  
  55.         -- Start the Level Sequence:
  56.         if( con == false and GameState == InLevel ) then    
  57.             G.Mes( error )
  58.             levelRoutine = coroutine.create( LevelSequence )
  59.         end    
  60.     end    
  61. end
  62.